<?php

/*
 * Action -4$
 *
 * +1 card
 * +2 actions
 * You may discard a treasure, if you do, take a coin token
 * 
 */

class Plaza extends Card implements iAction, iKingdom, iGuilds, iCoinTokensRequired {

    public function __construct() {
        parent::__construct("Plaza", 4);
        $this->undoPlay = false;
        $this->undoBuy = false;
    }

    public function getDescription() {
        return array(
            "+1 card",
            "+2 actions",
            "You may discard a treasure, if you do, take a coin token");
    }

    public function play(Game $game, $isRealCard) {

        $drawed_cards = $game->drawCards(1);
        $game->addActions(2);
        ScreenDisplay::addScreenMessage($game, true, "get +2 actions  and draw " . nicePrint($drawed_cards), "gets +2 actions and draws " . sizeof($drawed_cards) . " cards");
        $playHand = $game->getPlayHand();
        $treasures = array();
        foreach ($playHand as $card) {
            if ($card instanceof iTreasure) {
                $treasures[] = $card;
            }
        }

        if (sizeof($treasures) > 0) {
            $treasures = getUniqueCards($treasures);
            $treasures[] = new Option(1, 'None');

            $output = MySocket::GetUserReply($game, Input_ChooseOne, $treasures, 1, 1, null, "Choose card to discard");
            $answer = $output[0];
            if ($answer != 'None') {
                $card = $game->moveCardFromPileToPile($answer, PlayHand, DiscardPile);

                ScreenDisplay::addScreenMessage($game, true, "discard " . nicePrint($card), " discards " . ScreenDisplay::$LMSG);

                $game->addCoinTokens(1);
                ScreenDisplay::addScreenMessage($game, false, " get 1 coin token", "gets 1 coin token");
            } else {
                ScreenDisplay::addScreenMessage($game, true, " discard nothing  ", " discards nothing");
            }
        } else {
            ScreenDisplay::addScreenMessage($game, true, "discard nothing  ", " discards nothing");
        }
    }

}

?>